﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using BlogsAPI;
using BlogsAPI.Sites;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace BlogAPIUnitTest
{
    /// <summary>
    /// "Проверим определение числа лайков во всех сервисах"
    /// </summary>
    [TestClass]
    public class ILike
    {
        private static void RunTest(BlogsAPI.Interfaces.ILike platform, Uri linkto)
        {
            Dictionary<string, int> oData = platform.GetLikes(linkto);
            Assert.IsNotNull(oData);
            Assert.IsTrue(oData.Count() > 0);
            foreach (var o in oData)
            {
                Debug.WriteLine(platform.GetType().Name+" ("+linkto.OriginalString+") "+o.Key + " = " + o.Value);
            }
            Assert.IsTrue(oData.Count(i=>i.Value>0) > 0);
        }

        [TestMethod]
        public void TestFacebook()
        {
            RunTest(new BlogsAPI.Sites.Facebook("EAACEdEose0cBAGqcmKM7Lc4iebVdNFrqNIP2xYhqZCUb1mcCsu1O3QMKMpJu8p6OcG3WFSIozhUcePekZC3uwgzN1df6YuJpsarjOAYWmrRzRd14PSE5dDZBtqeI8z2FXbSzcmIUJ76CUHiS0dxsOe1zl3rMdntRiJe2SoJiwZDZD"), 
                new Uri("http://www.youtube.com/watch?v=Lg2WjLysdI4"));
        }

        [TestMethod]
        public void TestGooglePlus()
        {
            RunTest(new GooglePlus(), new Uri("https://www.youtube.com/watch?v=NjYpH4oL5G8"));
        }

        [TestMethod]
        public void TestTwitter()
        {
            RunTest(new Twitter(), new Uri("http://www.youtube.com/watch?v=NjYpH4oL5G8"));
        }

        [TestMethod]
        public void TestVK()
        {
            RunTest(new Vkontakte(), new Uri("http://yandex.ru"));
            RunTest(new Vkontakte(), new Uri("http://www.yandex.ru"));
        }

        //[TestMethod]
        //public void TestYaRU()
        //{
        //    RunTest(new YaRu(), new Uri("http://yandex.ru"));
        //    RunTest(new YaRu(), new Uri("http://www.yandex.ru"));
        //}

        [TestMethod]
        public void TestMail()
        {
            //RunTest(new BlogsMail(), new Uri("http://mail.ru"));
            //RunTest(new BlogsMail(), new Uri("http://www.mail.ru"));
            RunTest(new BlogsMail(), new Uri("http://www.youtube.com/watch?v=Lg2WjLysdI4"));
        }

        [TestMethod]
        public void TestOk()
        {
            RunTest(new Odnoklassnik(), new Uri("http://tema.livejournal.com"));
        }
    }
}
